package com.tyfspring.core.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;

/**
 * @Description 文件资源加载器
 * @Author shallow
 * @Date 2023/4/5 3:07
 */

public class FileSystemResource implements Resource{

    private final File file;

    private final String path;

    public FileSystemResource(File file) {
        this.file = file;
        this.path = file.getPath(); //文件对应路径
    }

    public FileSystemResource(String path) {
        this.path = path;
        this.file = new File(path);//创建新文件
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return new FileInputStream(this.file);
    }

    public final String getPath(){
        return this.path;
    }
}
